#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

//============WiFi名称和密码================//
const char* ssid     = "MI";
const char* password = "asdfghjkl";
//==========目标服务器网址和端口==============//
const char* host = "116.62.81.138";  //api.seniverse.com
const uint16_t port = 80 ;
//===============地区设置===================//
String City = "宁波";//城市
String My_Key = "密钥";//禁止泄露
//===============OLED引脚===================//
#define SCREEN_WIDTH 128  // OLED显示宽度，以像素为单位
#define SCREEN_HEIGHT 64  // OLED显示高度，以像素为单位
#define OLED_MOSI   12    //D6
#define OLED_CLK   13     //D7
#define OLED_DC    14     //D5
#define OLED_CS    15     //D8
#define OLED_RESET 16     //D0 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
//=================变量=====================//
typedef struct  
{
   int Hour;
   int Minute;
   int Second;
   int Year;
   int Month;
   int Day;
}STime;       //时间日期结构体
typedef struct
{
   int gws;
   int gwg;
   int dws;
   int dwg;
   int sds;
   int sdg;
}dat;       //最高温最低温和湿度的结构体  十位和个位
typedef struct
{
  int zuigaowendu;
  int zuidiwendu;
  int shidu;
  int tianqitubiao;
}tianqixinxi; //高温最低温和湿度的结构体

tianqixinxi day1,day2,day3;
dat Nume;
STime dTime,hTime;
int OnTime = -1;   //计数显示变量  10s时间 5s今明后天天气
bool DatFlag = true; //处理接收json数据的标志位
unsigned long getTime = 0;  //获取网络天气和时间  5s请求一次
String inputString = "";  //接收到的数据
//请求URL
String url = "/v3/weather/daily.json?key=" + My_Key +"&location=" + City + "&language=zh-Hans&unit=c&start=0&days=3";
//请求数据
String urlDat = "key=" + My_Key +"&location=" + City + "&language=zh-Hans&unit=c&start=0&days=3";
WiFiClient client;
/*************************************************************************************
 * 使用取模软件：PCTOLCD 2002完美版 
 * 取模方式为：阴码，逐行式，顺序  
 * 字体：32X32 仿宋
 * 图标：60X60
**************************************************************************************/
static const unsigned char PROGMEM qintian[] =
{
//晴，天
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x01,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x1F,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,
0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,
0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0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00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char PROGMEM yintian[] =
{
//阴，天
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x0F,0x80,0x1F,0xFF,0xFF,0x80,0x00,0x00,0x00,0x3F,0xF0,0x3F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x7F,0xF8,0x7F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0xFF,0xFC,0x7F,0xFF,0xFF,
0xE0,0x00,0x00,0x01,0xFF,0xFE,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x07,0xF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x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char PROGMEM duoyun[] =
{
//多，云
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00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0xFF,0xFF,0xFF,0x80,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,
0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,
0x03,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char PROGMEM xiaoyu[] =
{
//小，雨
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1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0xFF,0xF0,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char PROGMEM zhongyu[] =
{
//中，雨
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00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xFF,0xFF,0xFC,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x01,0xE1,0xE0,0x00,0x00,0x00,
0x00,0x00,0x01,0xE1,0xE0,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char PROGMEM dayu[] =
{
//大，雨
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0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,0xE0,0x00,
0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x1C,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};
static const unsigned char PROGMEM jintian[][32] =
{
//今，明，后，天
{0x01,0x00,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x12,0x10,0x21,0x08,0xC1,0x06,0x00,0x00,0x1F,0xF0,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00},//"今",
{0x00,0x00,0x00,0xFC,0x7C,0x84,0x44,0x84,0x44,0x84,0x44,0xFC,0x7C,0x84,0x44,0x84,0x44,0x84,0x44,0xFC,0x7C,0x84,0x44,0x84,0x01,0x04,0x01,0x04,0x02,0x14,0x04,0x08},//"明",
{0x00,0x10,0x00,0xF8,0x1F,0x00,0x10,0x00,0x10,0x00,0x1F,0xFE,0x10,0x00,0x10,0x00,0x10,0x00,0x17,0xF8,0x14,0x08,0x24,0x08,0x24,0x08,0x44,0x08,0x87,0xF8,0x04,0x08},//"后",
{0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06}//"天",
};
static const unsigned char PROGMEM shidu[][32] =
{
//湿，度
{0x00,0x00,0x27,0xF8,0x14,0x08,0x14,0x08,0x87,0xF8,0x44,0x08,0x44,0x08,0x17,0xF8,0x11,0x20,0x21,0x20,0xE9,0x24,0x25,0x28,0x23,0x30,0x21,0x20,0x2F,0xFE,0x00,0x00},//"湿",
{0x01,0x00,0x00,0x80,0x3F,0xFE,0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x22,0x20,0x23,0xE0,0x20,0x00,0x2F,0xF0,0x24,0x10,0x42,0x20,0x41,0xC0,0x86,0x30,0x38,0x0E}//"度",
};
static const unsigned char PROGMEM tianqi[][32] =
{
//晴，阴，多，云，小，中，大，雨
{0x00,0x20,0x00,0x20,0x7B,0xFE,0x48,0x20,0x49,0xFC,0x48,0x20,0x4B,0xFE,0x78,0x00,0x49,0xFC,0x49,0x04,0x49,0xFC,0x49,0x04,0x79,0xFC,0x49,0x04,0x01,0x14,0x01,0x08},//"晴",
{0x00,0x00,0x7D,0xFC,0x45,0x04,0x49,0x04,0x49,0x04,0x51,0xFC,0x49,0x04,0x49,0x04,0x45,0x04,0x45,0xFC,0x45,0x04,0x69,0x04,0x52,0x04,0x42,0x04,0x44,0x14,0x48,0x08},//"阴",
{0x02,0x00,0x02,0x00,0x07,0xF0,0x08,0x20,0x38,0x40,0x04,0x80,0x03,0x40,0x0C,0x80,0x71,0xF8,0x02,0x08,0x0C,0x10,0x32,0x20,0x01,0x40,0x01,0x80,0x0E,0x00,0x70,0x00},//"多",
{0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x02,0x00,0x04,0x00,0x04,0x00,0x08,0x40,0x10,0x20,0x20,0x10,0x7F,0xF8,0x20,0x08,0x00,0x08},//"云",
{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x11,0x10,0x11,0x08,0x11,0x04,0x21,0x04,0x21,0x02,0x41,0x02,0x81,0x02,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00},//"小",
{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00},//"中",
{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06},//*"大",
{0x00,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xFC,0x41,0x04,0x41,0x04,0x49,0x44,0x45,0x24,0x41,0x04,0x49,0x44,0x45,0x24,0x41,0x04,0x41,0x14,0x40,0x08}//*"雨",
};
static const unsigned char PROGMEM num[][16] =
{
// 0，1，2，3，4，5，6，7，8，9，-
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},//*"0",
{0x00,0x00,0x00,0x08,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},//*"1",
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x02,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},//*"2",
{0x00,0x00,0x00,0x3C,0x42,0x42,0x02,0x04,0x18,0x04,0x02,0x42,0x42,0x3C,0x00,0x00},//*"3",
{0x00,0x00,0x00,0x04,0x0C,0x0C,0x14,0x24,0x24,0x44,0x7F,0x04,0x04,0x1F,0x00,0x00},//*"4",
{0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x78,0x44,0x02,0x02,0x42,0x44,0x38,0x00,0x00},//*"5
{0x00,0x00,0x00,0x18,0x24,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x22,0x1C,0x00,0x00},//*"6",
{0x00,0x00,0x00,0x7E,0x42,0x04,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x00,0x00},//*"7",
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},//*"8",
{0x00,0x00,0x00,0x38,0x44,0x42,0x42,0x42,0x46,0x3A,0x02,0x02,0x24,0x18,0x00,0x00},//*"9",
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00}//*-
};
static const unsigned char PROGMEM sheshidu[][32] =
{
// ℃，％
{0x60,0x00,0x91,0xF4,0x96,0x0C,0x6C,0x04,0x08,0x04,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x0C,0x04,0x06,0x08,0x01,0xF0,0x00,0x00},
{0x00,0x00,0x18,0x04,0x24,0x08,0x24,0x10,0x24,0x20,0x24,0x40,0x24,0x80,0x19,0x00,0x02,0x60,0x04,0x90,0x08,0x90,0x10,0x90,0x20,0x90,0x40,0x90,0x00,0x60,0x00,0x00},//*"％",
};
//====================================================数组END=======================================================================//
void setup() {
    Serial.begin(9600);
    //检测OLED
    if(!display.begin(SSD1306_SWITCHCAPVCC)) {
        Serial.println(F("SSD1306 allocation failed"));//SSD1306分配失败
        for(;;); // 不要继续，永远循环
    }
    // 在屏幕上显示初始显示缓冲区的内容-Adafruit库
    display.display();//送显示
    delay(1000);  // 等待1s
    display.clearDisplay();//关闭显示
    display.setTextColor(WHITE);//设置字体颜色
    display.setTextSize(1);//设置字体大小
    display.setCursor(0,0);//设置光标
    display.printf("connecting to %s\n",ssid);//在OLED上打印信息
    display.display();
  
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
  
    while (WiFi.status() != WL_CONNECTED) //等待连接
    {
        delay(500);
        display.print(".");
        display.display();
    }
    display.println();
    display.println("WiFi connected");
    display.print("IP: ");
    display.println(WiFi.localIP());
    display.print("Please wait...");
    display.display();
}

void loop()
{
    GET_Weather();  //获取天气
    DateHandle();   //json处理
    DisplayTime();  //显示时间
    DisplayTianqi();//显示天气
}

/**************************************************
 * 函数名称：tianqi_dat
 * 函数功能：将最低温度，最高温度，湿度的个位 十位分离
 * 参数说明：dw 最低温，gw 最高温，sd 湿度
**************************************************/
void tianqi_dat(int dw,int gw,int sd)
{
      Nume.dws = dw/10;
      Nume.dwg = dw%10;
      Nume.gws = gw/10;
      Nume.gwg = gw%10;
      Nume.sds = sd/10;
      Nume.sdg = sd%10;    
}
/*****************************************************
 * 函数名称：显示天气函数
 * 参数说明：
 * dday：第几天
 * tq：  天气
 * dw：  最低气温
 * gw：  最高气温
 * sd：  湿度
******************************************************/
void display_tq(int dday,int tq,int dw,int gw,int sd)
{
    tianqi_dat(dw,gw,sd);
    display.clearDisplay();
    switch(dday)
    {
        case 0:display.drawBitmap(64,0,jintian[0],16,16,1);//今
        break;  
        case 1:display.drawBitmap(64,0,jintian[1],16,16,1);//
        break;
        case 2:display.drawBitmap(64,0,jintian[2],16,16,1);//
        break;
    }  
    display.drawBitmap(80,0,jintian[3],16,16,1);//天
    switch(tq)
    {
        case 0:display.drawBitmap(64,16,tianqi[0],16,16,1);//qin
               display.drawBitmap(0,0,qintian,60,60,1);//图标
        break;  
        case 4:display.drawBitmap(64,16,tianqi[2],16,16,1);//dy
               display.drawBitmap(80,16,tianqi[3],16,16,1);//
               display.drawBitmap(0,0,duoyun,60,60,1);//图标
        break;  
        case 9:display.drawBitmap(64,16,tianqi[1],16,16,1);//yin
               display.drawBitmap(0,0,yintian,60,60,1);//图标
        break;
        case 13:display.drawBitmap(64,16,tianqi[4],16,16,1);//x
               display.drawBitmap(80,16,tianqi[7],16,16,1);//
               display.drawBitmap(0,0,xiaoyu,60,60,1);//图标
        break;  
        case 14:display.drawBitmap(64,16,tianqi[5],16,16,1);//z
               display.drawBitmap(80,16,tianqi[7],16,16,1);//
               display.drawBitmap(0,0,zhongyu,60,60,1);//图标
        break;  
        case 15:display.drawBitmap(64,16,tianqi[6],16,16,1);//d
               display.drawBitmap(80,16,tianqi[7],16,16,1);//
               display.drawBitmap(0,0,dayu,60,60,1);//图标
        break;  
    }
    display.drawBitmap(64,32,num[Nume.dws],8,16,1);//最低温
    display.drawBitmap(72,32,num[Nume.dwg],8,16,1);//最低温
    
    display.drawBitmap(80,32,num[10],8,16,1);//-
    
    display.drawBitmap(88,32,num[Nume.gws],8,16,1);//最g温
    display.drawBitmap(96,32,num[Nume.gwg],8,16,1);//最g温
    
    display.drawBitmap(108,32,sheshidu[0],16,16,1);//shehisdu
    display.drawBitmap(64,48,shidu[0],16,16,1);//湿
    display.drawBitmap(80,48,shidu[1],16,16,1);//度  
    
    display.drawBitmap(96,48,num[Nume.sds],8,16,1);//湿度
    display.drawBitmap(104,48,num[Nume.sdg],8,16,1);//
    
    display.drawBitmap(112,48,sheshidu[1],16,16,1);//baifenhao
    display.display();
}
/**************************************************
 * 函数名称：DisplayZZXS
 * 函数功能：传入第几天将天气数据存入
 * 参数说明：dday
**************************************************/
void DisplayZZXS(int dday)
{
    switch(dday)
    {
        case 0:display_tq(dday,day1.tianqitubiao,day1.zuidiwendu,day1.zuigaowendu,day1.shidu);
        break;  
        case 1:display_tq(dday,day2.tianqitubiao,day2.zuidiwendu,day2.zuigaowendu,day2.shidu);
        break;  
        case 2:display_tq(dday,day3.tianqitubiao,day3.zuidiwendu,day3.zuigaowendu,day3.shidu);
        break;  
    }
}
/**************************************************
 * 函数名称：DisplayTianqi
 * 函数功能：显示天气
 * 参数说明：无
**************************************************/
void DisplayTianqi()
{
   if(OnTime > 1)
    {
        DisplayZZXS(OnTime-2);
        //Serial.println("打印天气中");  
    }
}
/**************************************************
 * 函数名称：DisplayTime
 * 函数功能：显示时间
 * 参数说明：无
**************************************************/
void DisplayTime()
{
    if(OnTime ==0 or OnTime == 1)
    {
        display.clearDisplay();//清除缓冲区
        display.setTextSize(2);//设置字体大小
        display.setCursor(32,0);//设置光标
        display.print("NingBo");//显示地区
        //display.setCursor(16,20);//设置光标
        //display.printf("%d:%d:%d",dTime.Hour,dTime.Minute,dTime.Second);
        display.setCursor(34,20);//设置光标
        display.printf("%d:%d",dTime.Hour,dTime.Minute);//时间
        display.setCursor(4,40);//设置光标
        display.printf("%d.%d.%d",dTime.Year,dTime.Month,dTime.Day);//日期
        display.display();
    }
}
/**************************************************
 * 函数名称：GET_Weather
 * 函数功能：http访问获取天气数据
 * 参数说明：无
**************************************************/
void GET_Weather()
{
    if((millis() - getTime > 5000))//10s
    {
        getTime = millis();
        //Serial.print("connecting to ");
        if (!client.connect(host,port)) 
        {
            Serial.println("服务器连接失败");
            return;
        }    
        //Serial.print("Requesting URL: ");
        // 发送请求报文
        client.print(String("GET ") + url + " HTTP/1.1\r\n" +  //请求行  请求方法 ＋ 请求地址 + 协议版本
                     "Host: " + host + "\r\n" +                //请求头部
                     "Connection: close\r\n" +                //处理完成后断开连接
                     "\r\n" +                                 //空行
                     urlDat);                                 //请求数据            
        delay(100);  
        while(client.available()) //接收数据
        {          
            String line = client.readStringUntil('\r');
            inputString += line;
        }
       // Serial.println(inputString);
        client.stop();      //断开与服务器连接以节约资源
        DatFlag = true;
       // Serial.println(inputString);
    }
}
/**************************************************
 * 函数名称：DateHandle
 * 函数功能：将获取到的数据进行处理
 * 参数说明：无
**************************************************/
void DateHandle()
{
    if(DatFlag)
    {
        DatFlag = false;
        int t = inputString.indexOf("Date:");//找时间
        int m = inputString.lastIndexOf("GMT");
        String inputTime = inputString.substring(t, m + 1); //把含有时间的数据取出进行处理
        int miao = inputTime.lastIndexOf(":");
        hTime.Hour = (inputTime.substring(miao-5, miao-3)).toInt();
        hTime.Minute = (inputTime.substring(miao-2, miao)).toInt();
        hTime.Second = (inputTime.substring(miao+1, miao+3)).toInt();
        //Serial.println(inputTime);
        int jsonBeginAt = inputString.indexOf("{");   //判断json数据完整性
        int jsonEndAt = inputString.lastIndexOf("}");
        if (jsonBeginAt != -1 && jsonEndAt != -1) 
        {
            //净化json数据
            inputString = inputString.substring(jsonBeginAt, jsonEndAt + 1);//取得一个完整的JSON字符串
            processMessage();//对数据进行处理
            //Serial.println(inputString);
            inputString="";
        }
    }  
}
/**************************************************
 * 函数名称：processMessage
 * 函数功能：将json数据取出
 * 参数说明：无
**************************************************/
void processMessage()
{
    const size_t capacity = JSON_ARRAY_SIZE(1) + JSON_ARRAY_SIZE(3) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(6) + 3*JSON_OBJECT_SIZE(13) + 760;
    DynamicJsonDocument doc(capacity);
    deserializeJson(doc, inputString);
    JsonObject results_0 = doc["results"][0];
    JsonObject results_0_location = results_0["location"];
    const char* results_0_location_name = results_0_location["name"]; // "宁波"
    JsonArray results_0_daily = results_0["daily"];
    JsonObject results_0_daily_0 = results_0_daily[0];
    const char* results_0_daily_0_date = results_0_daily_0["date"]; // "2019-12-21"==========================今天日期
    const char* results_0_daily_0_text_day = results_0_daily_0["text_day"]; // "中雨"=========================白天天气
    const char* results_0_daily_0_code_day = results_0_daily_0["code_day"]; // "14"==========================图标编号
    const char* results_0_daily_0_text_night = results_0_daily_0["text_night"]; // "中雨"=====================晚上天气
    const char* results_0_daily_0_code_night = results_0_daily_0["code_night"]; // "14"=======================图标编号
    const char* results_0_daily_0_high = results_0_daily_0["high"]; // "11"===================================最高气温
    const char* results_0_daily_0_low = results_0_daily_0["low"]; // "9"======================================最低气温
    const char* results_0_daily_0_wind_direction = results_0_daily_0["wind_direction"]; // "东北"==============风向
    const char* results_0_daily_0_wind_direction_degree = results_0_daily_0["wind_direction_degree"]; // "45"==度数
    const char* results_0_daily_0_wind_speed = results_0_daily_0["wind_speed"]; // "25.20"=====================速度
    const char* results_0_daily_0_wind_scale = results_0_daily_0["wind_scale"]; // "4"=========================风标
    const char* results_0_daily_0_humidity = results_0_daily_0["humidity"]; // "94"============================湿度
    
    JsonObject results_0_daily_1 = results_0_daily[1];
    const char* results_0_daily_1_date = results_0_daily_1["date"]; // "2019-12-22"
    const char* results_0_daily_1_text_day = results_0_daily_1["text_day"]; // "小雨"
    const char* results_0_daily_1_code_day = results_0_daily_1["code_day"]; // "13"
    const char* results_0_daily_1_text_night = results_0_daily_1["text_night"]; // "阴"
    const char* results_0_daily_1_code_night = results_0_daily_1["code_night"]; // "9"
    const char* results_0_daily_1_high = results_0_daily_1["high"]; // "12"
    const char* results_0_daily_1_low = results_0_daily_1["low"]; // "8"
    const char* results_0_daily_1_precip = results_0_daily_1["precip"]; // ""
    const char* results_0_daily_1_wind_direction = results_0_daily_1["wind_direction"]; // "西"
    const char* results_0_daily_1_wind_direction_degree = results_0_daily_1["wind_direction_degree"]; // "270"
    const char* results_0_daily_1_wind_speed = results_0_daily_1["wind_speed"]; // "25.20"
    const char* results_0_daily_1_wind_scale = results_0_daily_1["wind_scale"]; // "4"
    const char* results_0_daily_1_humidity = results_0_daily_1["humidity"]; // "91"
    
    JsonObject results_0_daily_2 = results_0_daily[2];
    const char* results_0_daily_2_date = results_0_daily_2["date"]; // "2019-12-23"
    const char* results_0_daily_2_text_day = results_0_daily_2["text_day"]; // "小雨"
    const char* results_0_daily_2_code_day = results_0_daily_2["code_day"]; // "13"
    const char* results_0_daily_2_text_night = results_0_daily_2["text_night"]; // "小雨"
    const char* results_0_daily_2_code_night = results_0_daily_2["code_night"]; // "13"
    const char* results_0_daily_2_high = results_0_daily_2["high"]; // "12"
    const char* results_0_daily_2_low = results_0_daily_2["low"]; // "11"
    const char* results_0_daily_2_precip = results_0_daily_2["precip"]; // ""
    const char* results_0_daily_2_wind_direction = results_0_daily_2["wind_direction"]; // "东北"
    const char* results_0_daily_2_wind_direction_degree = results_0_daily_2["wind_direction_degree"]; // "59"
    const char* results_0_daily_2_wind_speed = results_0_daily_2["wind_speed"]; // "34.20"
    const char* results_0_daily_2_wind_scale = results_0_daily_2["wind_scale"]; // "5"
    const char* results_0_daily_2_humidity = results_0_daily_2["humidity"]; // "86"
    
    const char* results_0_last_update = results_0["last_update"]; // "2019-12-21T17:23:52+08:00"
    
    String riqi = results_0_last_update;  //将日期取出处理
    int nian = riqi.lastIndexOf("T");
    hTime.Year = (riqi.substring(nian-10, nian-6)).toInt();
    hTime.Month = (riqi.substring(nian-5, nian-3)).toInt();
    hTime.Day = (riqi.substring(nian-2, nian)).toInt();
    
    OnTime++;   //显示标志位 0,1,2显示时间 3显示今天天气 4显示明天天气 5显示后天天气
    OnTime%=5;
    dTime.Hour = hTime.Hour+8;   
    dTime.Minute = hTime.Minute;
    dTime.Second = hTime.Second;
    dTime.Year = hTime.Year;
    dTime.Month = hTime.Month;
    dTime.Day = hTime.Day;

    day1.tianqitubiao = atoi(results_0_daily_0_code_day);//获取今天天气信息
    day1.zuigaowendu = atoi(results_0_daily_0_high);
    day1.zuidiwendu = atoi(results_0_daily_0_low);
    day1.shidu = atoi(results_0_daily_0_humidity);
    
    day2.tianqitubiao = atoi(results_0_daily_1_code_day);
    day2.zuigaowendu = atoi(results_0_daily_1_high);
    day2.zuidiwendu = atoi(results_0_daily_1_low);
    day2.shidu = atoi(results_0_daily_1_humidity);    
      
    day3.tianqitubiao = atoi(results_0_daily_2_code_day);
    day3.zuigaowendu = atoi(results_0_daily_2_high);
    day3.zuidiwendu = atoi(results_0_daily_2_low);
    day3.shidu = atoi(results_0_daily_2_humidity);
}
